import React, { Component } from "react";
// NavLink可以用来代替Link组件，额外加了一个导航高亮的功能
// 当选中的那个Link，会自动地加上active的类名
import { NavLink, Route, Switch } from "react-router-dom";

import "./style.css";

class Home extends Component {
  render() {
    return <div>home页面</div>;
  }
}

class About extends Component {
  render() {
    return <div>about页面</div>;
  }
}

class Mine extends Component {
  render() {
    return <div>mine页面</div>;
  }
}

class App extends Component {
  render() {
    return (
      <>
        <h3>react-router-导航高亮</h3>
        <ul>
          <li>
            {/* activeStyle表示独立的导航高亮 */}
            {/* activeClassName改变高亮的类名 */}
            <NavLink
              to="/home"
              activeClassName="select"
              // activeStyle={{
              //   fontSize: 30,
              // }}
            >
              home
            </NavLink>
          </li>
          <li>
            <NavLink to="/about" activeClassName="select">
              about
            </NavLink>
          </li>
          <li>
            <NavLink to="/mine" activeClassName="select">
              mine
            </NavLink>
          </li>
        </ul>

        <hr />

        <Switch>
          <Route path="/home" component={Home}></Route>
          <Route path="/about" component={About}></Route>
          <Route path="/mine" component={Mine}></Route>
        </Switch>
      </>
    );
  }
}

export default App;
